import request from './request';

export function request_login(params) {
    return request.post('/admin/login', params)
}

export function request_logout(params) {
    return request.post('/admin/logout', params)
}

// 余额变动列表
export function request_balance_list(params) {
    return request.post('/admin/user/getBlanceLog', params)
}

// 卡密列表
export function request_code_list(params) {
    return request.post('/admin/setting/getCodes', params)
}


// 卡密兑换
export function request_build_code(params) {
    return request.post('//admin/setting/getCodes', params)
}

export function request_content_get(params) {
    return request.post('/admin/setting/getContent', params)
}

export function request_content_update(params) {
    return request.post('/admin/setting/updateContent', params)
}

// 车辆列表
export function request_cars(params) {
    return request.post('/admin/car/getList', params)
}
// 用户列表
export function request_users(params) {
    return request.post('/admin/user/getList', params)
}
// 充值订单
export function request_exchange_order(params) {
    return request.post('/admin/order/getList', params)
}

export function request_download_form(params) {
    request.post('/admin/form/getList', params, { responseType: 'blob' }).then(function (response) {
        const url = window.URL.createObjectURL(new Blob([response.data]))
        const link = document.createElement('a')
        link.href = url
        link.setAttribute('download', '报名记录.xlsx')
        document.body.appendChild(link)
        link.click()
    })
}

// 套餐
export function request_package_list(params) {
    return request.post('/admin/setting/getListByPackage', params)
}

export function request_package_create(params) {
    return request.post('/admin/setting/createByPackage', params)
}

export function request_package_update(params) {
    return request.post('/admin/setting/updateByPackage', params)
}

export function request_package_delete(params) {
    return request.post('/admin/setting/deleteByPackage', params)
}

// 门店
export function request_store_list(params) {
    return request.post('/admin/store/getList', params)
}

export function request_store_create(params) {
    return request.post('/admin/store/create', params)
}

export function request_store_update(params) {
    return request.post('/admin/store/update', params)
}

export function request_store_delete(params) {
    return request.post('/admin/store/delete', params)
}

//  工位
export function request_station_list(params) {
    return request.post('/admin/station/getList', params)
}

export function request_station_create(params) {
    return request.post('/admin/station/create', params)
}

export function request_station_update(params) {
    return request.post('/admin/station/update', params)
}

export function request_station_delete(params) {
    return request.post('/admin/station/delete', params)
}


// 轮播图
export function request_banner_list(params) {
    return request.post('/admin/banner/getList', params)
}

export function request_banner_create(params) {
    return request.post('/admin/banner/create', params)
}

export function request_banner_update(params) {
    return request.post('/admin/banner/update', params)
}

export function request_banner_delete(params) {
    return request.post('/admin/banner/delete', params)
}

// 公告
export function request_notice_list(params) {
    return request.post('/admin/notice/getList', params)
}

export function request_notice_create(params) {
    return request.post('/admin/notice/create', params)
}

export function request_notice_update(params) {
    return request.post('/admin/notice/update', params)
}

export function request_notice_delete(params) {
    return request.post('/admin/notice/delete', params)
}

// 报名部分
export function request_form_list(params) {
    return request.post('/admin/form/getList', params)
}

export function request_form_create(params) {
    return request.post('/admin/form/create', params)
}

export function request_form_update(params) {
    return request.post('/admin/form/update', params)
}

export function request_form_delete(params) {
    return request.post('/admin/form/delete', params)
}

export function request_getbranchs(params) {
    return request.post('/api/user/getBranchs', params)
}

// 管理员部分
export function request_manger_get(params) {
    return request.post('/admin/manager/index', params)
}

export function request_manger_create(params) {
    return request.post('/admin/manager/add', params)
}

export function request_manger_update(params) {
    return request.post('/admin/manager/modify', params)
}

export function request_manger_delete(params) {
    return request.post('/admin/manager/delete', params)
}

export function request_manger_find(params) {
    return request.post('/admin/manager/get', params)
}

export function request_manger_switch(params) {
    return request.post('/admin/manager/switch', params)
}

export function request_user_info(params) {
    return request.post('/admin/manager/getUserInfo', params)
}

export function request_download_form(params) {
    request.post('/admin/form/getList', params, { responseType: 'blob' }).then(function (response) {
        const url = window.URL.createObjectURL(new Blob([response.data]))
        const link = document.createElement('a')
        link.href = url
        link.setAttribute('download', '报名记录.xlsx')
        document.body.appendChild(link)
        link.click()
    })
}

export function request_download_form2(params) {
    request({ // 用axios发送post请求
        method: 'post',
        url: '/admin/form/getList', // 请求地址
        data: params, // 参数
        responseType: 'blob' // 表明返回服务器返回的数据类型
      })
        .then((response) => { // 处理返回的文件流
            const url = window.URL.createObjectURL(new Blob([response.data]))
            const link = document.createElement('a')
            link.href = url
            link.setAttribute('download', '导出报表.xlsx')
            document.body.appendChild(link)
            link.click()
      })
}

export function post(url, params) {
    return request.post(url, params)
}

export function del(url, params) {
    return request.delete(url, {
        params
    })
}

export function put(url, params) {
    return request.put(url, params)
}